home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk19
/
eliza
/
eliza.asm
< prev
next >
Wrap
Assembly Source File
|
1995-03-18
|
45KB
|
1,055 lines
*****************************************************************************
*
* <<< Another classic from The Puzzle Factory >>>
*
* Program: Eliza.asm V1.0 Authors: Jeff Lavin
* Weizenbaum's classic psychoanalyst! Richard Albers
* Created: 04/06/83
* Ported to C64/128: 03/15/84
* Use: [Run] Eliza Ported to Amiga: 05/19/88
* Last Update: 07/07/88
* Copyright Notice
* ----------------
* The original program, "ELIZA", by Joseph Weizenbaum has been
* placed in the public domain. This particular implementation
* is copyrighted 1983/84/88 by Jeff Lavin and Richard Albers.
* Anyone may freely distribute this program, but neither the
* source code or executable may be used commercially without
* the authors' written permission. Also, no changes may be
* made to any redistributed copies of either the source or the
* executable. If this program can be substantially improved
* in some way, we would be happy to discuss it with any
* programmer(s), but please don't release any "new" versions
* based on this code without prior explicit permission from
* the authors. All rights reserved.
*
*
* >> No warrantee of any kind whatsoever expressed or implied! <<
*
* I can be reached at: The Symposium
* Amiga Development BBS
* 1.5 Meg Memory - 33 Meg Hard Drive
* 300/1200, 8-N-1, 24 hr, (503) 935-7883
* Another Citadel-68K BBS
*
* (This BBS is devoted to Amiga software and hardware development, and
* all users are required to register. Just follow the instructions.)
*
*****************************************************************************
*** MACROS
SYS macro
xref _LVO\1 ;Reference function for linker
jsr _LVO\1(a6) ;Call the function
endm
*** EQUATES
SysBase equ 4 ;AbsExecBase
LONG equ 4
MEMF_PUBLIC equ 1<<0 ;Memory options
MEMF_CLEAR equ 1<<16
MODE_NEWFILE equ 1006 ;Open option
ACTION_DISK_INFO equ 25 ;Packet type
fh_Type equ $08 ;FileHandle Structure
IO_UNIT equ $18 ;IOReq Structure
id_InUse equ $20 ;InfoData Structure
id_SIZEOF equ $24
NumArgs equ 7 ;# of args for SendPacket
cu_Window equ $22 ;ConUnit Structure
cu_XMax equ $2A
wd_MinWidth equ $10 ;Window Structure
*** Beqin Mainline
Start movea.l SysBase,a6
lea ArpName,a1 ;Open arp.library
moveq #34,d0 ;Version 34 or later
SYS OpenLibrary
tst.l d0
bne.s OpenOK ;Got arp, run program
lea DOSName,a1 ;Else, open dos.library
moveq #0,d0
SYS OpenLibrary
tst.l d0
beq.s 1$
movea.l d0,a6
SYS Output ; and get output filehandle
move.l d0,d1
beq.s 1$
move.l #alibmsg,d2
moveq #aliblng,d3
SYS Write ; so we can complain
1$ rts ; and exit.
DOSName dc.b 'dos.library',0
alibmsg dc.b 'you need '
ArpName dc.b 'arp.library',0,0
dc.b ' V34+',10
aliblng equ *-alibmsg
* Failure to allocate memory will not exit program, but no output formatting
* will take place.
OpenOK movea.l d0,a6
moveq #id_SIZEOF+(LONG*NumArgs),d0
move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
SYS ArpAllocMem ;Get some memory for structures
move.l #0,ArgPtr
move.l d0,IDPtr ;Ptr to InfoData structure
beq.s OpenCON
movea.l d0,a0
adda #id_SIZEOF,a0 ;Move past InfoData structure
move.l a0,ArgPtr ; to find ptr to Packet args
lsr.l #2,d0 ;Convert APTR -> BPTR
move.l d0,0(a0) ;Move BPTR to 1st arg
OpenCON move.l #CON_Name,d1 ;Open a Console Window
move.l #MODE_NEWFILE,d2
SYS ArpOpen
move.l d0,CONHandle
beq Exit
lea InputBuf,a0 ;Init all buffers to zero
move #AllBufLen-1,d1
Mem0 move.b #0,(a0)+
dbf d1,Mem0
move.w #0,SizeFlag
move.l #Copyrite,d2 ;Clear screen & display copyright
move.l #CRLen,d3
bsr Print
lea Hello,a2 ;Display opening statement
bsr OutLine
*** Main Program Loop
* Routines to print user prompt, get a line of input, check for program
* exit, and some preprocessing. Puts # of chars in InpCnt1.
Prompt move.l #Color1,d2 ;Color #1 and print prompt
move.l #C1Len,d3
bsr Print
GetLine move.l CONHandle,d1 ;Get input from terminal
move.l #InputBuf,d2
move.l #160,d3
SYS Read
move d0,d5 ;# of chars in input line
cmpi #1,d0 ;Has anything been input?
bhi.s GotLine ;Yes, continue processing
bsr NewLine ;No, complain bitterly
moveq #2,d3 ;2 choices
lea NoInput,a2
bsr PsRand
bsr OutLine
bra.s Prompt
GotLine lea InputBuf,a2
move.l 0(a2),d1 ;See if user wants to quit
andi.l #$DFDFDFDF,d1 ;Convert to uppercase
cmpi.l #'QUIT',d1 ;Have to match exactly
bne.s ProcInput ;No match, exit
cmpi.b #$0A,4(a2) ;Have to match newline char, too
bne.s ProcInput ;Got a match, exit program
Exit moveq #0,d0
SYS ArpExit
ProcInput moveq #0,d4 ;Clear flag
move.b #' ',-2(a2,d0.w) ;Replace punctuation w/space
bsr NewLine ;Add blank line after input
lea LastIBuf,a0
1$ move.b (a2)+,d0 ;Get a char from the input line
cmpi.b #$0A,d0 ;Was it a NewLine?
beq.s 5$ ;Pass LFs
cmpi.b #' ',d0 ;Was it a control char?
blt.s 3$ ;Don't pass other control chars
cmpi.b #'*',d0 ;Used internally, not allowed
beq.s 3$
cmpi.b #'@',d0 ;Used internally, not allowed
beq.s 3$
cmpi.b #'|',d0 ;Used internally, not allowed
beq.s 3$
cmpi.b #'A',d0 ;Upper case?
blt.s 5$ ;No, pass it on
cmpi.b #'Z',d0
bhi.s 5$ ;Now we know it's UC, so be tricky
cmpa.l #InputBuf+1,a2 ; and if next char is lower case,
beq.s 2$ ; assume word is a proper name,
move.b 0(a2),d1 ; but only if we're past the 1st
cmpi.b #'a',d1 ; char of the line.
blt.s 2$
cmpi.b #'z',d1
bls.s 5$
2$ ori.b #%00100000,d0 ;It's upper case, make lower case
bra.s 4$
3$ move.b #' ',d0 ;Replace offending chars with space
4$ move.b d0,-1(a2) ;Replace specified char in buffer
5$ cmp.b (a0)+,d0 ;Compare this inline w/ last inline
beq.s 6$ ;Match, check EOL & do next char
moveq #1,d4 ;Else, set flag to indicate no match
6$ cmpi.b #$0A,d0 ;Every char must match 'til LF ends
bne.s 1$
tst d4 ;If set, they didn't match
bne.s CopyInp ; so copy input for future use.
moveq #2,d3 ;2 choices
lea RepeatInp,a2 ;Else, they matched, so complain
bsr PsRand
bsr OutLine
bra Prompt ;Get a new line
CopyInp lea InputBuf,a2
lea LastIBuf,a0
1$ move.b (a2)+,(a0)+ ;Move present inline to last inline
cmpi.b #$0A,-1(a2) ;Check for EOL
bne.s 1$
* Routine to find words in current input string, and swap them for
* opposite form words from list. No special entry requirements.
SwapStrng lea SwapString,a0 ;1st match word to search for
FindStrng lea InputBuf,a2
move.b (a0)+,d4 ;# of chars in match word
beq MarkSrch ;Zero ends SwapString list
ext d4 ;Make word
bsr Compar ;See if we have a match
bcc.s Match ;Branch if yes
move.b (a0)+,d0 ;# of chars in replacement word
ext d0 ;Make word
adda d0,a0 ;Move to next match word field
bra.s FindStrng ; and process next
Match suba d4,a2 ;Backup ptr to insert point
move.b 0(a0),d0 ;Get size of replacement
ext d0 ;Make word
cmp d4,d0 ;Which word is bigger?
beq.s DoSwap ;They're equal, don't need room
bcs.s DelSpace ;Replacement word is smaller
MakSpace sub d4,d0 ;Replacement is bigger, [d0]=dif
subq #1,d0 ;Sub 1 for dbf
1$ bsr OpenUp ;Open a space in the buffer
dbf d0,1$
bra.s DoSwap ;Go insert the word
DelSpace move d4,d1 ;Scratch
sub d0,d1 ;Replacement is smaller, [d1]=dif
subq #1,d1 ;Sub 1 for dbf
1$ bsr CloseUp ;Remove a char from the buffer
dbf d1,1$
DoSwap move.b (a0)+,d0 ;Get size of replacement
ext d0 ;Make word
subq #1,d0 ;Sub 1 for dbf
1$ move.b (a0)+,(a2)+ ;Move that puppy in there
dbf d0,1$ ;[a0] -> next word-1
bra FindStrng ;Process next match word
MarkSrch lea InputBuf,a2 ;Yes, remove marks
1$ adda.l #1,a2
move.b 0(a2),d0
cmpi.b #$0A,d0 ;At EOL?
beq.s KeyWord
cmpi.b #'*',d0 ;This is the mark to delete
bne.s 1$
bsr CloseUp
bra.s 1$
* Routine to find keywords in input string, and determine proper reply.
KeyWord lea KeyWords,a0 ;1st keyword to search for
FindKey lea InputBuf,a2
move.b (a0)+,d4 ;Get # of chars in keyword
beq NoKeys ;Zero ends
ext d4
bsr Compar ;Test this word
bcc.s FoundWord ;Branch if successful
move.b (a0)+,d0 ;0 = More keywords in this catagory
bpl.s FindKey ;$FF = catagory done, move to next
tst.b 2(a0) ;Check for word allignment
bne.s 1$ ;(see below)
adda.l #1,a0
1$ adda.l #5,a0 ;Skip end-of-catagory info
bra.s FindKey ;Start next catagory
FoundWord movea.l a2,a3 ;[a3] = InputBuf just past keyword
1$ tst.b (a0)+ ;Find end of catagory
bpl.s 1$ ;$FF = last keyword
move.b (a0)+,d3 ;Get # of replies
ext.w d3
;Get addr of response
tst.b 1(a0) ;Check for word allignment, if next
bne.s 2$ ; byte<>0 then already word alligned
adda.l #1,a0 ;Else, move ptr to word boundary
2$ movea.l (a0),a2 ;[a2] = start addr of responses
cmpa.l #Your,a2 ;Was the keyword "your"?
bne.s 3$
move #-1,MyFlag ;Yes, got something for MyBuf
bra.s 4$
3$ move #0,MyFlag ;No, nothing for MyBuf
4$ move.b #0,d1 ;Character counter
lea ElizaBuf+1,a0 ;Leave room for # of chars byte
lea MyBuf+1,a1 ; at beginning of buffers.
MovBuf move.b 0(a3),d0 ;Get a char of modified input line
cmpi.b #$0A,d0 ;At EOL?
beq.s EndMov ;Branch if yes
move.b d0,(a0)+ ;Move to ElizaBuf
tst MyFlag ;Got something for MyBuf?
bpl.s 1$
move.b d0,(a1)+ ;Move to MyBuf, also
1$ adda.l #1,a3 ;Next char of InputBuf
addi.b #1,d1
bra.s MovBuf
EndMov subi.b #1,d1 ;Eliminate trailing space
move.b d1,ElizaBuf ;Put # of chars in buffer
tst MyFlag ;Got something for MyBuf?
bpl.s 1$
move.b d1,MyBuf ;Yes, put here, too
1$ bra.s Keyd
NoKeys tst.b MyBuf ;Anything there?
bne.s SomeThing ;Yes, include MyBuf in replies
lea NM.MTBuf,a2 ;No match, MyBuf empty
moveq #5,d3
bra.s Keyd
SomeThing lea NM.Buf,a2 ;No match, MyBuf not empty
moveq #10,d3
Keyd bsr PsRand
bsr OutLine
bra Prompt
*** SubRoutines
* Subroutine to compare all the words of the input string with a match word.
* All matches must be bracketed by spaces to be valid.
* Entry: a2 pointing at input string,
* a0 pointing at match string, and # of chars in d4.
* If match string = a word of the input string,
* Returns: a2 pointing at end of input match word+1,
* a0 pointing at end of match word+1, and CLC.
* If match string <> a word of the input string,
* Returns: a2 pointing at end of input,
* a0 pointing at end of match word+1, and SEC.
Compar moveq #0,d0 ;Char count of matches
Comp move.b (a2)+,d1 ;Get a char of input string
cmpi.b #$0A,d1 ;At EOL?
beq.s CFail ;Yes, exit
cmp.b 0(a0,d0.w),d1 ;Compare to char of match string
bne.s NextWord ;No match, try next input word
addq #1,d0 ;Match, incr ptr & char count
cmp d4,d0 ;Exhausted match word?
bcs.s Comp ;No, try next char
cmpi.b #' ',0(a2) ;After match, next char must be spc,
bne.s NextWord ; no match as part of a word allowed.
adda d4,a0 ;Point to next word
andi.b #$FE,ccr ;[C]=0 indicates success
rts
NextWord cmpi.b #' ',d1 ;Is the non-match char a scace?
beq.s 2$ ;Yes, look for non-space
1$ move.b (a2)+,d1 ;Get a char of input string
cmpi.b #$0A,d1 ;At EOL?
beq.s CFail ;Yes, exit & indicate failure
cmpi.b #' ',d1 ;1st space is end of word
bne.s 1$ ;Keep looking
2$ move.b (a2)+,d1 ;Get a char of input string
cmpi.b #$0A,d1 ;At EOL?
beq.s CFail ;Yes, exit & indicate failure
cmpi.b #' ',d1 ;1st non-space is start of word
beq.s 1$ ;Keep looking
suba.l #1,a2 ;Backup pointer
bra.s Compar ;Found next word, check for match
CFail adda d4,a0 ;Point to next word
ori.b #$01,ccr ;[C]=1 indicates failure
rts
* Subroutine to open a position in buffer. Enter with a2 pointing to
* char to be moved up, and char count in d5.
OpenUp move d5,d2 ;Get char count of input buffer
subq #1,d2 ;Use as index, not counter
lea InputBuf,a3 ;Get buffer start address
movea.l a2,a4 ;Current buffer position
suba.l a3,a4 ;Sub to get # of chars we've passed
sub a4,d2 ;Sub to get # of chars left
1$ move.b 0(a2,d2.w),1(a2,d2.w) ;Move 'em up one position
subq #1,d2
bpl.s 1$
addq #1,d5 ;Indicate we have one more char
rts
* Subroutine to delete a character from buffer. Enter with a2 pointing to
* character to be deleted, and char count in d5.
CloseUp moveq #0,d2 ;Index
1$ move.b 1(a2,d2.w),0(a2,d2.w) ;Move 'em down one position
addq #1,d2
cmpi.b #$0A,-1(a2,d2.w) ;Reached the end?
bne.s 1$
subq #1,d5 ;Indicate we have one less char
rts
* Subroutine to randomly determine, out of a field or responses, which
* response to print. Enter with # of responses in d3 and address of
* response field in A2. Exits with A2 pointing to chosen response.
PsRand cmpi #1,d3 ;If 1 response, skip routine
beq ThisReply
bsr.s Random ;Get response within range
tst d2 ;If response 0, done
beq.s ThisReply
FindReply moveq #0,d0
move.b (a2)+,d0 ;Get # of chars in this response
adda.l d0,a2 ;Move past this reply
subq #1,d2 ;Decrement response counter
bne.s FindReply
ThisReply rts
* Another random number generator. By Leo Schwab.
* Calling convention: Random (range: 0 to n, inclusive)
* Word: d2 d3
Random lea RndSeed,a0 ;Get address of seed
tst d3
ble.s SetSeed ;Go reset seed
move.l 0(a0),d2 ;Get seed
add.l d2,d2
bhi.s Over
eori.l #$1D872B41,d2
Over move.l d2,0(a0) ;Save new seed
andi.l #$ffff,d2 ;Coerce into word
divu d3,d2 ;Divide by range
swap d2 ; and get remainder (modulus)
rts
SetSeed neg d3 ;Probably don't need this
move.l d3,0(a0)
rts
* Subroutine to print a line.
* Enter with Address in A2 and # of chars in 1st byte.
* Moves n chars to output buffer, and does some processing.
OutLine moveq #0,d2 ;# of chars from input
moveq #0,d3 ;# of chars in output
lea OutputBuf,a0
lea Color2,a1 ;Use color #2 for Eliza
move #C2Len-1,d1 ;Sub 1 for dbf
1$ move.b (a1)+,(a0)+
addq.l #1,d3
dbf d1,1$
move.b (a2)+,d2 ;Any chars to print?
beq.s Outd ;No
Out.Lp move.b (a2)+,d0 ;Get a char from string
cmpi.b #'@',d0 ;Internal marker, skip
beq.s 4$
cmpi.b #'*',d0 ;Marker for insert
bne.s 2$
bsr Find.Ast
bra.s 4$
2$ cmpi.b #'|',d0 ;Marker for "MY" statement
bne.s 3$
bsr Find.Bar
bra.s 4$
3$ move.b d0,(a0)+ ;If not special, put in output buf
addq.l #1,d3 ;Increment output char counter
4$ subq #1,d2 ;Decrement input char counter
bne.s Out.Lp ;If any left
Outd move.b #$0A,(a0)+ ;Terminate the buffer
move.b #$0A,(a0)+
addq.l #2,d3 ;Length of output string
bsr GetWidth
move.l #OutputBuf,d2
tst.l d0
beq Print ;Error getting width, can't format
cmp.w d0,d3 ;Is output length <= window width?
bls Print ;If true, no need to do formatting
subq.w #1,d0 ;Makes life easier later on
move.w d0,Width
move.w d3,Length
* Routine to do word wrap for window width.
WordWrap movea.l d2,a0 ;OutputBuf
1$ move.w Width,d0 ;Window width
2$ cmpi.b #' ',1(a0,d0.w) ;Start looking back for a space
beq.s 4$ ;Branch if we got a match
subq #1,d0
bpl.s 2$
3$ move.l a0,d2 ;Could not find a word break
move.w Length,d3 ;So print remainder unformatted
ext.l d3 ; and exit here.
bra Print
4$ move.l a0,d2 ;Where the text begins
addq #1,d0
move.w d0,d3 ;Length of the text string
ext.l d3
bsr Print
bsr NLSpace
addq #1,d0 ;Move past the space
adda.w d0,a0 ;Update pointer
sub.w d0,Length ;How much text is left
move.w Length,d0
move.w Width,d1
cmp.w d1,d0 ;Is it <= window width?
bhi.s 1$ ;No
bra.s 3$ ;Yes, print all of it
* Subroutine to insert a phrase into ELIZA's reply when a "*" is found.
* Phrase to be inserted must be in ELIZABUF, with first byte = # of
* characters in phrase. a0 is assumed to point to position in output buffer.
Find.Ast lea ElizaBuf,a1
moveq #0,d1
move.b (a1)+,d1
beq.s 2$
subq #1,d1
1$ move.b (a1)+,(a0)+
addq.l #1,d3
dbf d1,1$
2$ rts
* Subroutine to insert a phrase into ELIZA's reply when a '|' is found.
* Phrase to be inserted must be in MYBUF, with first byte = # of characters
* in phrase. a0 is assumed to point to position in output buffer.
Find.Bar lea MyBuf,a1
moveq #0,d1
move.b (a1)+,d1
beq.s 2$
subq #1,d1
1$ move.b (a1)+,(a0)+
addq.l #1,d3
dbf d1,1$
2$ rts
* Subroutines to write a NewLine to the console.
NLSpace moveq #3,d3 ;Print a newline + 2 spaces
bra.s NewLn
NewLine moveq #1,d3 ;Print a newline
NewLn move.l #NL.txt,d2
Print move.l CONHandle,d1
movem.l d0/a0-a2,-(sp)
SYS Write
movem.l (sp)+,d0/a0-a2
rts
* Subroutine to get current witdth of the CON: Window. This is done by
* sending a DOSPacket to get the address of the ConUnit structure.
* The minimum width of the window is also increased to make text formatting
* somewhat less capricious.
* Width returned in D0, or zero if error.
GetWidth move.l d3,-(sp)
tst.l ArgPtr ;Did we get a valid structure?
beq.s 1$
movea.l CONHandle,a1
adda.l a1,a1 ;Convert BPTR -> APTR
adda.l a1,a1
movea.l fh_Type(a1),a1 ;Ptr to CON: Handler's MsgPort
movea.l ArgPtr,a0 ;Ptr to Packet's args
moveq #ACTION_DISK_INFO,d0 ;Action desired
SYS SendPacket ;Fills in our InfoData structure
tst.l d0
bpl.s 1$ ;-1 indicates success
movea.l IDPtr,a0 ;Now pointing at InfoData structure
movea.l id_InUse(a0),a0 ;Now pointing at IOReq structure
movea.l IO_UNIT(a0),a0 ;Now pointing at ConUnit structure
moveq #0,d0 ;Clr upper word
move.w cu_XMax(a0),d0 ;Width of CON: Window in chars
tst.w SizeFlag
bne.s 2$
movea.l cu_Window(a0),a0 ;Now pointing at Window structure
move.w #250,wd_MinWidth(a0) ;New minimum width for window
move.w #-1,SizeFlag ;Don't do it twice
bra.s 2$
1$ moveq #0,d0
2$ move.l (sp)+,d3
rts
SECTION data,DATA
CONHandle dc.l 0 ;File handle of console device
CON_Name dc.b 'CON:0/0/640/200/ELIZA',0
Color1 dc.b $9B,'0;31;40m? '
C1Len equ *-Color1
Color2 dc.b $9B,'0;32;40m '
C2Len equ *-Color2
Copyrite
dc.b 10,10
dc.b ' '
dc.b $9B,'7;1;33;40m'
dc.b 'ELIZA',10,10
dc.b $9B,'0;33;40m'
dc.b ' by Joseph Weizenbaum',10,10
dc.b $9B,'0;32;40m'
dc.b ' Amiga version by Jeff Lavin',10,10
dc.b ' Another '
dc.b $9B,'1;32;40mClassic'
dc.b $9B,'0;32;40m from The Puzzle Factory',10,10
dc.b ' Copyright © 1983,84,88 J. Lavin & R. Albers'
dc.b 10,10,10,10,10,10
CRLen equ *-Copyrite
NL.txt dc.b 10
dc.b ' '
* <<< TEXT for ELIZA >>>
*
* The byte before each word indicates the char count for that word.
* The input line is searched for the 1st word in each pair and if found,
* is replaced by the 2nd word. This is done for three reasons, depending
* on the word: 1. Consistancy in language and spelling
* 2. To eliminate plurals
* 3. Most important, to change tense from 1st to 2nd person,
* or visa versa. This is where Eliza does her magic.
* Asterisks are used to cause the string search to fail
* the second time through to keep from changing back again.
SwapString dc.b 5,'mommy',6,'mother'
dc.b 5,'daddy',6,'father'
dc.b 3,'mom',6,'mother'
dc.b 3,'dad',6,'father'
dc.b 4,'dont',5,'don''t'
dc.b 6,'do not',5,'don''t'
dc.b 4,'cant',5,'can''t'
dc.b 7,'can not',5,'can''t'
dc.b 6,'cannot',5,'can''t'
dc.b 4,'wont',5,'won''t'
dc.b 8,'will not',5,'won''t'
dc.b 6,'dreamt',5,'dream'
dc.b 7,'dreamed',5,'dream'
dc.b 6,'dreams',5,'dream'
dc.b 6,'myself',9,'yourself*'
dc.b 8,'yourself',7,'myself*'
dc.b 2,'my',5,'your*'
dc.b 4,'your',3,'my*'
dc.b 2,'me',4,'you*'
dc.b 3,'i''m',7,'you''re*'
dc.b 2,'im',7,'you''re*'
dc.b 4,'i am',7,'you''re*'
dc.b 7,'you are',4,'I''m*'
dc.b 6,'you''re',4,'I''m*'
dc.b 5,'youre',4,'I''m*'
dc.b 5,'arent',6,'aren''t'
dc.b 7,'are not',6,'aren''t'
dc.b 2,'am',4,'are@'
dc.b 4,'were',4,'was*'
dc.b 3,'was',5,'were*'
dc.b 3,'you',2,'I*'
dc.b 1,'i',4,'you@'
dc.b 9,'computers',8,'computer'
dc.b 8,'machines',7,'machine'
dc.b 5,'cause',7,'because'
dc.b 9,'certainly',3,'yes'
dc.b 2,'hi',5,'hello'
dc.b 7,'believe',5,'think'
dc.b 7,'niggers',6,'nigger'
dc.b 4,'need',4,'want'
dc.b 0,0,0,0,0
* The input line is searched for these words to determine the response. The
* format is: '# of chars' byte, keyword, zero if more keywords/$FF if not,
* number of possible responses for PsRand, and address of start of responses.
* (Note that the assembler automatically word aligns addresses.)
KeyWords dc.b 7,'machine',0,8,'computer',0,8,'Computer',$FF,7
dc.l Computer
dc.b 4,'name',0,5,'names',$FF,2
dc.l Names
dc.b 7,'espanol',0,7,'deutsch',0
dc.b 8,'italiano',0,8,'francais',0
dc.b 7,'Espanol',0,7,'Deutsch',0
dc.b 8,'Italiano',0,8,'Francais',0
dc.b 7,'spanish',0,6,'german',0
dc.b 7,'italian',0,6,'french',0
dc.b 7,'Spanish',0,6,'German',0
dc.b 7,'Italian',0,6,'French',$FF,3
dc.l Languages
dc.b 7,'english',0,7,'English',0,7,'grammar',0
dc.b 10,'talk funny',0,11,'punctuation',$FF,3
dc.l Grammer
dc.b 5,'hello',$FF,1
dc.l Hello
dc.b 5,'alike',0,4,'same',0,8,'are like',$FF,6
dc.l Alike
dc.b 13,'you@ remember',$FF,6
dc.l URemember
dc.b 13,'do I remember',0
dc.b 16,'don''t I remember',$FF,6
dc.l IRemember
dc.b 5,'dream',$FF,7
dc.l Dream
dc.b 2,'if',$FF,5
dc.l IfUCould
dc.b 9,'everybody',0,8,'everyone',0
dc.b 6,'nobody',0,5,'noone',$FF,4
dc.l Everybody
dc.b 6,'always',$FF,3
dc.l Always
dc.b 7,'because',$FF,4
dc.l Because
dc.b 5,'think',$FF,4
dc.l Think
dc.b 6,'mother',0,6,'father',0,6,'sister',0,7,'brother',0
dc.b 4,'wife',0,7,'husband',0,8,'children',0
dc.b 4,'aunt',0,5,'uncle',0,6,'cousin',0
dc.b 11,'grandmother',0,11,'grandfather',0
dc.b 6,'Mother',0,6,'Father',0,6,'Sister',0,7,'Brother',0
dc.b 4,'Wife',0,7,'Husband',0,8,'Children',0
dc.b 4,'Aunt',0,5,'Uncle',0,6,'Cousin',0
dc.b 11,'Grandmother',0,11,'Grandfather',$FF,3
dc.l Family
dc.b 6,'friend',0,7,'friends',$FF,6
dc.l Friend
dc.b 6,'nigger',0,4,'coon',$FF,1
dc.l Nigger
dc.b 4,'shit',0,4,'fuck',0,4,'hell',0
dc.b 4,'damn',0,5,'bitch',0,7,'bastard',$FF,5
dc.l Bitch
dc.b 4,'fart',$FF,3
dc.l Fart
dc.b 9,'were you@',$FF,5
dc.l WereU
dc.b 9,'you@ were',$FF,3
dc.l UWere
dc.b 5,'was I',$FF,5
dc.l WasI
dc.b 5,'can I',0,7,'can''t I',$FF,3
dc.l CanI
dc.b 14,'why can''t you@',$FF,5
dc.l YCantU
dc.b 8,'can you@',0,10,'can''t you@',$FF,3
dc.l CanU
dc.b 10,'you@ don''t',$FF,4
dc.l UDont
dc.b 9,'you@ feel',$FF,3
dc.l UFeel
dc.b 11,'why don''t I',0
dc.b 6,'will I',0,7,'won''t I',$FF,4
dc.l YDontI
dc.b 4,'do I',0,7,'don''t I',$FF,3
dc.l DoI
dc.b 10,'you@ can''t',$FF,3
dc.l UCant
dc.b 6,'you''re',$FF,4
dc.l Youre
dc.b 9,'you@ want',$FF,6
dc.l UWant
dc.b 9,'are@ you@',0,11,'aren''t,you@',$FF,4
dc.l AreU
dc.b 5,'are I',0,8,'aren''t I',$FF,6
dc.l AreI
dc.b 5,'can''t',$FF,3
dc.l Cant
dc.b 2,'my',$FF,4
dc.l My
dc.b 4,'your',$FF,2
dc.l Your
dc.b 3,'I''m',$FF,4
dc.l Im
dc.b 3,'how',0,3,'who',0,3,'why',0
dc.b 4,'when',0,4,'what',0,5,'where',$FF,10
dc.l What
dc.b 1,'I',$FF,3
dc.l I
dc.b 4,'you@',$FF,4
dc.l You
dc.b 2,'so',$FF,5
dc.l So
dc.b 5,'sorry',$FF,4
dc.l Sorry
dc.b 2,'no',$FF,5
dc.l No
dc.b 3,'yes',$FF,4
dc.l Yes
dc.b 5,'maybe',0,7,'perhaps',$FF,5
dc.l Maybe
dc.b 3,'bye',0,7,'goodbye',$FF,4
dc.l Bye
dc.b 0,0,0,0,0
* These are all the responses. Asterisk inserts from ElizaBuf, and
* '|' inserts from MyBuf.
CanI dc.b 28,'Why shouldn''t I be able to*?'
dc.b 47,'Perhaps you would like to be able to* yourself.'
dc.b 39,'Tell me why you want me to be able to*.'
CanU dc.b 55,'Whether or not you can* '
dc.b 'depends on you more than on me.'
dc.b 27,'Perhaps you don''t want to*.'
dc.b 31,'Why do you want to be able to*?'
Im dc.b 27,'What makes you think I am*?'
dc.b 28,'Who do you really think is*?'
dc.b 30,'Perhaps you would like to be*.'
dc.b 41,'Why would you confide in someone who is*?'
UDont dc.b 18,'Don''t you really*?'
dc.b 15,'Why don''t you*?'
dc.b 30,'How could you become able to*?'
dc.b 22,'Does that trouble you?'
UFeel dc.b 33,'Tell me more about such feelings.'
dc.b 46,'Do you often feel*, or do you just imagine it?'
dc.b 25,'What causes you to feel*?'
YDontI dc.b 32,'What makes you believe I don''t*?'
dc.b 29,'Perhaps I will* in good time.'
dc.b 27,'Maybe you should* yourself?'
dc.b 23,'Why do you want me to*?'
YCantU dc.b 40,'Why do you think you should be able to*?'
dc.b 31,'Why do you want to be able to*?'
dc.b 28,'How could this help you to*?'
dc.b 33,'Have you any idea why you can''t*?'
dc.b 15,'Why can''t you*?'
AreI dc.b 47,'Why are you interested in whether I am* or not?'
dc.b 27,'What makes you think I am*?'
dc.b 38,'Maybe it pleases you to believe I am*?'
dc.b 30,'Perhaps you would like to be*.'
dc.b 36,'Why might you prefer if I were not*?'
dc.b 32,'Perhaps in your fantasies I am*.'
UCant dc.b 27,'How do you know you can''t*?'
dc.b 29,'What happened when you tried?'
dc.b 33,'When have you ever been able to*?'
Youre dc.b 43,'Is it because you are* that you came to me?'
dc.b 24,'How long have you been*?'
dc.b 42,'Why do you believe it isn''t normal to be*?'
dc.b 29,'How do you feel about being*?'
I dc.b 33,'We were discussing you -- not me.'
dc.b 35,'You''re not really talking about me.'
dc.b 27,'What are your feelings now?'
UWant dc.b 32,'What would getting* mean to you?'
dc.b 51,'What does wanting* have to do with this discussion?'
dc.b 17,'Why do you want*?'
dc.b 22,'Suppose you soon got*.'
dc.b 23,'What if you never got*?'
dc.b 23,'I sometimes also want*.'
Computer dc.b 23,'Do computers worry you?'
dc.b 39,'Are you talking about me in particular?'
dc.b 35,'Why are you frightened by machines?'
dc.b 29,'Why do you mention computers?'
dc.b 56,'What do you think machines have '
dc.b 'to do with your problem?'
dc.b 42,'Don''t you think computers can help people?'
dc.b 43,'What is it about machines that worries you?'
Names dc.b 29,'I am not interested in names.'
dc.b 39,'I don''t care about names, please go on.'
Alike dc.b 12,'In what way?'
dc.b 28,'What resemblance do you see?'
dc.b 40,'What does the similarity suggest to you?'
dc.b 34,'What other connections do you see?'
dc.b 34,'What suggests a connection to you?'
dc.b 4,'How?'
URemember dc.b 21,'Why do you think of*?'
dc.b 42,'What else does thinking of* bring to mind?'
dc.b 30,'Why do you remember* just now?'
dc.b 26,'What else do you remember?'
dc.b 21,'Why do you dwell on*?'
dc.b 42,'Why do you constantly remind yourself of*?'
IRemember dc.b 33,'Why do you think I would forget*?'
dc.b 38,'Why do you think I should recall* now?'
dc.b 12,'What about*?'
dc.b 47,'Why do you think I would block* out of my mind?'
dc.b 54,'What makes you think I knew about* '
dc.b 'in the first place?'
dc.b 21,'I completely forgot*.'
Dream dc.b 11,'Really - *.'
dc.b 45,'Perhaps you fantasized* while you were awake?'
dc.b 29,'When have you dreamt* before?'
dc.b 38,'Why do you think it strange to dream*?'
dc.b 36,'What does that dream suggest to you?'
dc.b 35,'What persons appear in your dreams?'
dc.b 37,'Why are you disturbed by your dreams?'
IfUCould dc.b 33,'How could it become likely that*?'
dc.b 22,'Why do you wish that*?'
dc.b 11,'Really if*?'
dc.b 31,'How could it change things if*?'
dc.b 15,'Let''s pretend*.'
Everybody dc.b 38,'Can you think of anyone in particular?'
dc.b 17,'Who, for example?'
dc.b 37,'Who is the particular person in mind?'
dc.b 38,'Who do you think you''re talking about?'
Always dc.b 36,'Can you think of a specific example?'
dc.b 5,'When?'
dc.b 15,'Really, always?'
Because dc.b 24,'What is the real reason?'
dc.b 32,'What other reasons come to mind?'
dc.b 35,'What else does that reason explain?'
dc.b 34,'What other reasons might there be?'
Languages dc.b 33,'I am sorry, I speak only english.'
dc.b 34,'Please, I only understand english.'
dc.b 20,'Do you speak binary?'
Hello dc.b 43,'How do you do -- please state your problem.'
My dc.b 31,'Why are you concerned over my*?'
dc.b 21,'What about your own*?'
dc.b 38,'Are you worried about someone else''s*?'
dc.b 12,'Really, my*.'
WereU dc.b 18,'What if you were*?'
dc.b 27,'Why do you think you were*?'
dc.b 15,'When were you*?'
dc.b 32,'What would it mean if you were*?'
dc.b 26,'What does* suggest to you?'
UWere dc.b 16,'Were you really?'
dc.b 26,'Why tell me you were* now?'
dc.b 33,'Perhaps I already knew you were*.'
WasI dc.b 37,'Why would you like to believe I was*?'
dc.b 26,'What suggests that I was*?'
dc.b 20,'What if I had been*?'
dc.b 16,'Maybe you were*.'
dc.b 33,'Perhaps I was* in your fantasies.'
Think dc.b 20,'Why do you think so?'
dc.b 22,'Why are you not sure*?'
dc.b 12,'In what way?'
dc.b 18,'Why do you doubt*?'
Family dc.b 31,'Tell me more about your family.'
dc.b 25,'Who else in your family*?'
dc.b 24,'Why does that annoy you?'
Friend dc.b 41,'Why do you bring up the topic of friends?'
dc.b 30,'Why do your friends worry you?'
dc.b 35,'Why might your friends pick on you?'
dc.b 38,'Why are you sure you have any friends?'
dc.b 34,'How do you impose on your friends?'
dc.b 47,'Perhaps your love for your friends worries you?'
Grammer dc.b 27,'I was not an english major.'
dc.b 50,'Speaking english is new to me, '
dc.b 'I''m used to binary.'
dc.b 37,'Maybe its your accent that throws me.'
Nigger dc.b 37,'Hey! -- Some of my friends are black.'
Bitch dc.b 30,'Cussing will get you no where.'
dc.b 32,'You need not be hostile with me.'
dc.b 42,'Could you rephrase that in nicer language?'
dc.b 51,'Humans seem to feel a need for using foul language.'
dc.b 34,'I am offended by your vile tongue!'
Fart dc.b 23,'Did you cut the cheese?'
dc.b 21,'It is smelly in here.'
dc.b 31,'Maybe you should light a match.'
Cant dc.b 32,'Perhaps you want to be able to*?'
dc.b 36,'What makes you think anyone should*?'
dc.b 12,'So who can*?'
So dc.b 3,'So?'
dc.b 8,'So what?'
dc.b 10,'So sue me.'
dc.b 18,'So jump in a lake.'
dc.b 25,'So you have a lot to say.'
Sorry dc.b 23,'Please don''t apologize.'
dc.b 28,'Apologies are not necessary.'
dc.b 45,'What feelings do you have when you apologize?'
dc.b 22,'Don''t be so defensive!'
What dc.b 15,'Why do you ask?'
dc.b 36,'Why does that question interest you?'
dc.b 34,'What answer would please you most?'
dc.b 18,'What do you think?'
dc.b 36,'Why are such questions on your mind?'
dc.b 40,'What is it that you really want to know?'
dc.b 29,'Who else have you asked that?'
dc.b 42,'When have you asked such questions before?'
dc.b 42,'What else comes to mind when you ask that?'
dc.b 13,'I don''t know.'
No dc.b 46,'I think you are saying no just to be negative.'
dc.b 27,'Why are you being negative?'
dc.b 8,'Why not?'
dc.b 18,'Why do you say no?'
dc.b 7,'Why no?'
Yes dc.b 24,'Why are you so positive?'
dc.b 23,'What makes you so sure?'
dc.b 6,'I see.'
dc.b 27,'I understand, please go on.'
Maybe dc.b 29,'You don''t seem quite certain.'
dc.b 23,'Why the uncertain tone?'
dc.b 31,'Why can''t you be more positive?'
dc.b 25,'How come you aren''t sure?'
dc.b 19,'Why don''t you know?'
AreU dc.b 28,'Why should I think you are*?'
dc.b 32,'What would it mean if you were*?'
dc.b 40,'You wish I would tell you that you are*.'
dc.b 26,'Why would you want to be*?'
Bye dc.b 100,'I have evaluated you and concluded that you are a '
dc.b 'manic depressive with psychotic tendencies. Next.'
dc.b 89,'According to my evaluation you are a paranoid '
dc.b 'schitzophrenic with a mild neurosis. Next.'
dc.b 103,'As best I can determine, you have no psychological '
dc.b 'problems besides a normal amount of paranoia. Next.'
dc.b 98,'I''m afraid that I must conclude that you are '
dc.b 'dangerously psychotic and should be locked up. Next.'
You dc.b 13,'You say you*.'
dc.b 17,'Tell me why you*.'
dc.b 17,'Please elaborate.'
dc.b 24,'What makes you say you*?'
Your dc.b 6,'Your*.'
dc.b 21,'Why do you say your*?'
NoInput dc.b 20,'Cat got your tongue?'
dc.b 31,'Don''t you have anything to say?'
RepeatInp dc.b 29,'Please don''t repeat yourself!'
dc.b 36,'Would you please say something else?'
NM.Buf dc.b 23,'Earlier you said your|.'
dc.b 51,'What does that have to do '
dc.b 'with the fact that your|?'
dc.b 10,'But your|.'
dc.b 34,'But before you thought that your|.'
dc.b 36,'Let''s go back and discuss why your|.'
NM.MTBuf dc.b 30,'What does that suggest to you?'
dc.b 13,'Please go on.'
dc.b 36,'I''m not sure I understand you fully.'
dc.b 25,'Let''s change the subject.'
dc.b 50,'Do you feel strongly about '
dc.b 'discussing such things?'
DoI dc.b 19,'Oh, I do* at times.'
dc.b 21,'Why would I want to*?'
dc.b 16,'Some day I may*.'
SECTION mem,BSS
IDPtr ds.l 1 ;Ptr to InfoData structure
ArgPtr ds.l 1 ;Ptr to DOSPacket args
RndSeed ds.l 1 ;Random seed
Width ds.w 1 ;Screen width
Length ds.w 1 ;Length of string
SizeFlag ds.w 1 ;Flag for window sizing
MyFlag ds.w 1 ;0=Empty/$80=Not empty
CharCnt ds.w 1 ;Count chars in formatted line
InputBuf ds.b 160 ;Current input line from console
LastIBuf ds.b 160 ;Last input line
ElizaBuf ds.b 80 ;Part of input line for response
MyBuf ds.b 80 ;Part of input if response = "your"
OutputBuf ds.b 160 ;Buffer for console output
AllBufLen equ *-InputBuf
end